package com.xuebang.admin.util;

import java.util.Properties;

import org.springframework.mail.MailMessage;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

//import java.util.Properties;

/**
 * 本类测试简单邮件 直接用邮件发送
 * 
 * @author Administrator
 */
public class SingleMailSend {

	public static void sendmail(String message) {

		JavaMailSender sender = new JavaMailSenderImpl();
		((JavaMailSenderImpl) sender).setHost("smtp.bjcathay.com");
		((JavaMailSenderImpl) sender).setUsername("notify@bjcathay.com");
		((JavaMailSenderImpl) sender).setPassword("notify66994");

		Properties pro = System.getProperties();
		pro.put("mail.smtp.auth", "true");
		pro.put("mail.smtp.socketFactory.port", "25");
		pro.put("mail.smtp.socketFactory.fallback", "true");

		((JavaMailSenderImpl) sender).setJavaMailProperties(pro);

		// 创建基本邮件信息
		MailMessage mailMessage = new SimpleMailMessage();
		mailMessage.setFrom("notify@bjcathay.com");
		mailMessage.setSubject("告警邮件");
		mailMessage.setText("正文：" + message);
		mailMessage.setTo("wangb@bjcathay.com");

		sender.send((SimpleMailMessage) mailMessage);

	}
}
